var HistoryManager = new Object();
HistoryManager.Index = 0;
// 显示订单
function OpenSalesOrder(url) {
    OpenWindow2(url, "订单信息", 2);
}

// 设置下拉框只读
function SetSelectReadOnly(ddl) {
    ddl.outerHTML = ddl.outerHTML.replace("id=", "onbeforeactivate='return false' onfocus='this.blur()' onmouseover='this.setCapture()' onmouseout='this.releaseCapture()' id=");
}

// 防止按钮重复提交
function DisableClickAfterSubmit(buttonID) {
    document.getElementById(buttonID).disabled = true;
    document.body.style.cursor = "wait";
    if (document.aspnetForm.onsubmit == null || document.aspnetForm.onsubmit() == true) {
        __doPostBack(buttonID, "");
    }
    else {
        document.body.style.cursor = "";
        document.getElementById(buttonID).disabled = false;
    }
}

// 检查录入（整数）
function CheckNum() {
    code = this.event.keyCode;

    if (code > 57 || code < 48) {
        this.event.returnValue = false;
    }
}
// 检查录入
function CheckNumsObj(obj) {
    code = this.event.keyCode;

    if (code > 57 || code < 48) {
        if (code != 46) {
            this.event.returnValue = false;
        }
    }
}
// 检查录入
function CheckI(controlID, controlDesc, allowNull) { return Check(controlID, controlDesc, "I+", allowNull) }
function CheckN(controlID, controlDesc, allowNull) { return Check(controlID, controlDesc, "N+", allowNull) }
function Check(controlID, controlDesc, dataType, checkNull) {

    control = document.getElementById(controlID);
    if (control == null) return true;

    controlDesc = "[" + controlDesc + "]";
    controlValue = null;
    controlType = "";
    switch (controlType) {
        default: // "Text"
            controlValue = control.value;
            break;
    }

    // 检查空值
    if (checkNull == true && (controlValue.length == 0 || controlValue == "0" || controlValue == "-1")) {
        alert(controlDesc + "不能为空。");
        SetFocus(control);
        return false;
    }

    // 检查数据类型
    switch (dataType) {
        case "I":
            if (!IsNumber(controlValue, "-0123456789")) {
                alert(controlDesc + "格式不正确，请录入整数。");
                SetFocus(control);
                return false;
            }
            break;
        case "I+":
            if (!IsNumber(controlValue, "0123456789")) {
                alert(controlDesc + "格式不正确，请录入正整数。");
                SetFocus(control);
                return false;
            }
            break;
        case "I-":
            if (!IsNumber(controlValue, "0123456789", false)) {
                alert(controlDesc + "格式不正确，请录入负整数。");
                SetFocus(control);
                return false;
            }
            break;
        case "N":
            if (!IsNumber(controlValue, ".-0123456789")) {
                alert(controlDesc + "格式不正确，请录入数值。");
                SetFocus(control);
                return false;
            }
            break;
        case "N+":
            if (!IsNumber(controlValue, ".0123456789")) {
                alert(controlDesc + "格式不正确，请录入正数。");
                SetFocus(control);
                return false;
            }
            break;
        case "N-":
            if (!IsNumber(controlValue, "-.0123456789", false)) {
                alert(controlDesc + "格式不正确，请录入负数。");
                SetFocus(control);
                return false;
            }
            break;
        default: // "C"
            if (controlValue.length == 0 || controlValue == "-1") {
                alert(controlDesc + "不能为空。");
                SetFocus(control);
                return false;
            }
            break;
    }
    return true;
}

function SetFocus(control) {
    if (control == null) return;
    if (!control.disabled && control.style != null && control.style.display != "none") {
        try { control.focus(); } catch (e) { }
    }
}

// 判断是否整形
function IsInt(value, test) {
    return IsNumber(value, "0123456789");
}

// 判断是否数值
function IsNumber(value, test, isMinus) {
    if (value != null && value.length > 0) {
        Num_Test = ".-0123456789";
        if (test != null && test.length > 0) Num_Test = test;

        // 检查是否负数
        if (isMinus == true && value.charAt(0) != "-") {
            return false;
        }

        Char_Index = -1;
        Char_Value = "";
        for (i = 0; i < value.length; i++) {
            Char_Value = value.charAt(i);
            Num_Index = Num_Test.indexOf(Char_Value);
            if (Num_Index == -1) {
                return false;
            }
            else if (Char_Value == "-" && Num_Index != 0)	// -号必须在首位
            {
                return false;
            }
        }
    }
    return true;
}

// 检查日期范围
function CheckDateRange(dateB, dateE) {
    if (dateB.length > 0 && dateE.length > 0) {
        var arrB = dateB.split("-");
        var arrE = dateE.split("-");
        var dtmB = new Date(arrB[0], arrB[1], arrB[2]);
        var dtmE = new Date(arrE[0], arrE[1], arrE[2]);

        if (dtmB > dtmE) {
            return false;
        }
    }
    return true;
}

// 日期：格式化
Date.prototype.format = function(format) {
    var args = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds()
    };
    if (/(y+)/.test(format))
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var i in args) {
        var n = args[i];
        if (new RegExp("(" + i + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
    }
    return format;
}

// 日期：加天
Date.prototype.addDays = function(d) {
    this.setDate(this.getDate() + d);
};

// 日期：加周
Date.prototype.addWeeks = function(w) {
    this.addDays(w * 7);
};

// 日期：加月
Date.prototype.addMonths = function(m) {
    var d = this.getDate();
    this.setMonth(this.getMonth() + m);

    if (this.getDate() < d)
        this.setDate(0);
};

// 日期：加年
Date.prototype.addYears = function(y) {
    var m = this.getMonth();
    this.setFullYear(this.getFullYear() + y);

    if (m < this.getMonth()) {
        this.setDate(0);
    }
};

function myopen(sUrl, title) {
    if (sUrl == "") {
        alert('该记录未加入到流程！');
    }
    else {
        winOpen(sUrl + '&operation=view', 900, 550, title);
    }
}

// 保存后提示
function AfterSave(isPopup) {
    operation = "edit";
    if (document.all.txtOperation != null) operation = document.all.txtOperation.value;

    if (operation == "add") {
        if (confirm("操作成功！是否继续新增？") == true) {
            window.location.href = window.location.href;
        }
        else {
            if (document.all.txtURL != null) window.location.href = document.all.txtURL.value;
        }
    }
    else {
        alert("操作成功！");
        if (isPopup != null && isPopup == "1") {
            window.returnValue = "ok";
            window.close();
        }
        else {
            if (document.all.txtURL != null) window.location.href = document.all.txtURL.value;
        }
    }
}

// 更新缓存时间
function UpdateCacheTime() {
    ajax.Begin("Common_Core.dll", "Common_Core.MutiModel.CRM_BLL.CacheManager", null, "_ctl0_WorkForm_txtCacheKey", "Key=UpdateCacheTime");
}

// 更新缓存时间
function RemoveCache() {
    ajax.Begin("Common_Core.dll", "Common_Core.MutiModel.CRM_BLL.CacheManager", null, "_ctl0_WorkForm_txtCacheKey", "Key=RemoveCache");
}

// 打印
function Print() {
    // 打印预览 IE7会拦截
    //if (document.all.wb != null) document.all.wb.ExecWB(7,1);	

    //url = document.URL+"&Print=1";
    //OpenWindow(url,"打印",-1)

    // 隐藏按钮，隐藏下拉框
    fonts = document.getElementsByTagName("font");
    for (i = 0; i < fonts.length; i++) {
        if (fonts[i].outerText.indexOf("*") >= 0) fonts[i].outerText = " ";
    }

    buttons = document.getElementsByTagName("input");
    for (i = 0; i < buttons.length; i++) {
        if ((buttons[i].type == "button" || buttons[i].type == "submit") && buttons[i].style.display == "") buttons[i].style.display = "none";
    }

    selects = document.getElementsByTagName("select");
    for (i = 0; i < selects.length; i++) {
        if (selects[i].style.display == "") {
            //selects[i].outerHTML = "<input name='"+selects[i].id+"' id='"+selects[i].id+"' type='text' readOnly value='"+selects[i].options[selects[i].options.selectedIndex].text+"' style='width:90px;' />";			
            selects[i].outerHTML = "<input name='" + selects[i].id + "' id='" + selects[i].id + "' type='text' readOnly value='" + selects[i].options[selects[i].options.selectedIndex].text + "' style='width:" + selects[i].style.width + ";' />";
        }
    }

    // 网格
    rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {
        if (rows[i].id.indexOf("_LastRow") >= 0) {
            rows[i].style.display = "none";
        }
    }

    // 流程
    if (document.getElementById("divFlow") != null) document.getElementById("divFlow").style.display = "none";

    // 添加附件
    if (document.getElementById("FileAttachModel_tdAtt") != null) document.getElementById("FileAttachModel_tdAtt").style.display = "none";

    // 页面自己的打印前处理
    if (window.PrePrint != null) window.PrePrint();

    // 如果有标题，隐藏IE的标题	
    if (document.all.lblTitle != null) {
        document.title = "";
    }

    window.print();
    window.close();
    //alert("打印完成!");

}

function PrintGrid() {
}

function PrintSelectToText(ddl) {
    //ddl.outerHTML = "<input name='"+ddl.id+"' id='"+ddl.id+"' type='text' readOnly value='"+ddl.options[ddl.options.selectedIndex].text+"' style='width:"+ddl.style.width+";' />";			
    ddl.outerHTML = "<input name='" + ddl.id + "' id='" + ddl.id + "' type='text' readOnly value='" + ddl.value + "' style='width:" + ddl.style.width + ";' />";
}

function OpenChanceCenter(id) {
    OpenWindow3("/" + ApplicationPath() + "/CRM/Sales/SalesChanceCenter.aspx?operation=edit&id=" + id);
}

// 发送公文
var isSendDocFrist = true;
function SendDoc() {
    if (document.all.btnSend == null) return;
    if (__doPostBack == null) return;
    if (isSendDocFrist == true) {
        isSendDocFrist = false;
        return;
    }

    document.all.btnSend.disabled = true;
    __doPostBack('btnSend', '');
}

// 显示产品
function ActionView(id) {
    var sUrl = "/" + ApplicationPath() + "/Common/Product/ProductAdd.aspx?operation=view&ID=" + id;
    winOpen(sUrl, 800, 500);
}

// 显示办公用品申购计划
function ShowOfficePlan(type, id) {
}

// 根据账务类别返回单据url
function GetRecePayBillUrl(typeid) {
    url = "";
    if (typeid == 1) {
        url = "/" + ApplicationPath() + "/Common/RecePay/ReceBillEdit.aspx?operation=add"
    }
    else if (typeid == 2) {
        url = "/" + ApplicationPath() + "/Common/RecePay/PayBillEdit.aspx?operation=add"
    }
    return url;
}

// 培训计划
function ShowTrainingPlan(id) {
    url = "/" + ApplicationPath() + "/HR/Training/TrainingPlanEdit.aspx?operation=edit&id=" + id;
    OpenWindow2(url, "培训计划", 3);
}

// 培训项目
function ShowTrainingProject(id) {
    url = "/" + ApplicationPath() + "/HR/Training/TrainingProjectEdit.aspx?operation=view&id=" + id;
    OpenWindow2(url, "培训项目", 3);
}

// 分期结账
function InstalmentBalance(typeid, id) {
    url = GetRecePayBillUrl(typeid) + "&InstalmentID=" + id;
    OpenWindow2(url, "分期结账", 3);
}

// 应收应付款项结账
function RecePayBalance(typeid, id) {
    url = GetRecePayBillUrl(typeid) + "&RecePayID=" + id;
    OpenWindow2(url, "款项结账", 3);
}

// 应收应付款项结账
function RecePayDetailBalance(typeid, id) {
    url = GetRecePayBillUrl(typeid) + "&RecePayDetailID=" + id;
    OpenWindow2(url, "款项结账", 3);
}

// 应收应付款项结账（发票结算）
function InvoiceBalance(typeid, id) {
    url = GetRecePayBillUrl(typeid) + "&FromInvoice=" + id;
    OpenWindow2(url, "款项结账", 3);
}

// 应收应付款项结账（发票结算）
function InvoiceBalance2(typeid, id) {
    url = GetRecePayBillUrl(typeid) + "&InvoiceID=" + id;
    return OpenWindow(url, "款项结账", 3); ;
}

// 补发票
function AddInvoices(typeid, id) {
    bill = "ReceBillList.aspx";
    if (typeid == "2") bill = "PayBillList.aspx";
    backurl = "/" + ApplicationPath() + "/CRM/RecePay/" + bill + "$mode=invoiceRemind@index=1@operation=edit";
    url = "/" + ApplicationPath() + "/CRM/RecePay/InvoiceEdit.aspx?operation=add&from=addInvoices&balancetypeid=" + typeid + "&balanceid=" + id + "&BackURL=" + backurl;
    window.location.href = url;
}

// 将选中的款项写入坏账申请单
function NewBadDebtBill(idList) {
    url = "/" + ApplicationPath() + "/CRM/RecePay/BadDebtBillEdit.aspx?operation=add&idList=" + idList;
    OpenWindow2(url, "坏账审批单", 3);
}

// 显示应收应付明细的结账情况
function ShowBalanceInfo(typeid, recepayDetailID) {
    wShow("/Common/RecePay/RecePayDetailList.aspx?typeid=" + typeid + "&id=" + recepayDetailID, 840, 560);
}

// 显示分期计划
function ShowInstalment(id) {
    url = "/" + ApplicationPath() + "/CRM/RecePay/InstalmentEdit.aspx?operation=edit&id=" + id;
    OpenWindow2(url, "分期款项", 3);
}

// 显示收/付款单
function ShowRecePayBill(typeid, id, para) {
    if (typeid == "2") {
        ShowPayBill(id, para);
    }
    else {
        ShowReceBill(id, para);
    }
}

// 显示收款单
function ShowReceBill(id, para) {
    url = "/" + ApplicationPath() + "/Common/RecePay/ReceBillEdit.aspx?operation=edit&id=" + id;
    if (para != null) {
        if (para.substring(0, 1) != "&") url = url + "&";
        url = url + para;
    }
    OpenWindow2(url, "收款单", 3);
}

// 显示付款单
function ShowPayBill(id, para) {
    url = "/" + ApplicationPath() + "/Common/RecePay/PayBillEdit.aspx?operation=edit&id=" + id;
    if (para != null) {
        if (para.substring(0, 1) != "&") url = url + "&";
        url = url + para;
    }
    OpenWindow2(url, "付款单", 3);
}

// 显示销售订单
function ShowSalesOrder(id) {
    ShowBusinessObject("11", id)
}

// 显示合同
function ShowContract(id) {
    ShowBusinessObject("51", id)
}

// 显示发票
function ShowInvoice(id) {
    url = "/" + ApplicationPath() + "/CRM/RecePay/InvoiceEdit.aspx?operation=edit&id=" + id;
    OpenWindow2(url, "发票信息", 3);
}

// 显示发票结算信息
function ShowInvoiceBalanceInfo(balanceTypeID, pkid) {
    bill = "ReceBillList.aspx"
    if (balanceTypeID == "2") {
        bill = "PayBillList.aspx"
    }
    url = "/" + ApplicationPath() + "/CRM/RecePay/" + bill + "?Mode=RecePayFind&operation=view&invoiceID=" + pkid;
    OpenWindow2(url, "发票结算信息", 3);
}

// 设置发票状态
function SetInvoiceStatus(title, pkid, statusid) {
    url = "/" + ApplicationPath() + "/CRM/RecePay/InvoiceStatusEdit.aspx?title=" + title + "&pkid=" + pkid + "&statusid=" + statusid;
    OpenWindow2(url, title, 0);
}

// 显示业务对象信息
function ShowBusinessObject(typeid, id) {
    url = "";
    title = "";
    switch (typeid) {
        case "11":
            title = "销售订单";
            url = "/" + ApplicationPath() + "/CRM/Sales/SalesOrderEdit.aspx";
            break;
        case "51":
            title = "合同信息";
            url = "/" + ApplicationPath() + "/Common/Contract/ContractOpt.aspx";
            break;
        case "41":
            title = "收款单";
            url = "/" + ApplicationPath() + "/Common/RecePay/ReceBillEdit.aspx";
            break;
        case "42":
            title = "付款单";
            url = "/" + ApplicationPath() + "/Common/RecePay/PayBillEdit.aspx";
            break;
        case "43":
            title = "分期款项";
            url = "/" + ApplicationPath() + "/CRM/RecePay/InstalmentEdit.aspx"
            break;
        case "45":
            title = "坏账单";
            url = "/" + ApplicationPath() + "/CRM/RecePay/BadDebtBillEdit.aspx"
            break;
        case "61":
            title = "出票信息";
            url = "/" + ApplicationPath() + "/CRM/RecePay/InvoiceOutEdit.aspx"
            break;
        case "62":
            title = "采购订单";
            url = "/" + ApplicationPath() + "/DispartSell/Purchase/RecordPurchase.aspx"
            break;
        case "63":
            title = "采购退货单";
            url = "/" + ApplicationPath() + "/DispartSell/Purchase/PurBackEdit.aspx"
            break;
        case "47":
            title = "销售订单";
            url = "/" + ApplicationPath() + "/DispartSell/SaleManage/OrderOpt.aspx";
            break;
        case "48":
            title = "销售退货单";
            url = "/" + ApplicationPath() + "/DispartSell/SaleManage/WithdrawOpt.aspx";
            break;
        case "49":
            title = "现款销售单";
            url = "/" + ApplicationPath() + "/DispartSell/SaleManage/MoneySell.aspx";
            break;
        case "124":
            title = "猎头项目";
            url = "/" + ApplicationPath() + "/HMS/Projects/ProjectAdd.aspx";
            break;
    }

    if (url.length > 0) {
        if (typeid == "47" || typeid == "48" || typeid == "49" || typeid == "62" || typeid == "63") {
            url = url + "?operation=view&id=" + id;
        } else if (typeid == "124") {
            url = url + "?operation=view&type=2&ProjectID=" + id;
        }
        else {
            url = url + "?operation=edit&id=" + id;
        }
        OpenWindow2(url, title, 3);
    }
}

// 客户调查
function ClientInquire(typeid, fkid) {
    url = "/" + ApplicationPath() + "/Common/Client/ClientInquireInput.aspx?typeid=" + typeid + "&fkid=" + fkid;
    return OpenWindow(url, "客户调查", null, 250, 500);
}

// 获取单号
function GetOrderNo(businessType, txtid) {
    if (businessType == null || businessType.length == 0) {
        alert("未指定单号前缀。");
        return;
    }
    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.OrderBase', ShowOrderNo, null, 'Key=GetOrderNO&BusinessType=' + businessType)
}

// 显示单号
function ShowOrderNo() {
    if (ajax.Completed() == true) {
        if (document.all._ctl0_WorkForm_txtOrderNO != null) {
            txt = document.all._ctl0_WorkForm_txtOrderNO;
        }
        else if (document.all._ctl0_WorkForm_txtMLID != null) {
            txt = document.all._ctl0_WorkForm_txtMLID;
        }

        if (txt == null) {
            alert('单号文本框未指定。');
        }
        else {
            txt.value = ajax.GetText();
        }
    }
}

// 组织机构关联（显示部门）
function LoadDeptPersonnel(ddlParent, isPublic) {
    //ddl=document.getElementById("ddlDept");
    ddl = document.getElementById("_ctl0_WorkForm_ddlDept");
    ui.ClearSelect(ddl);

    //ddlSub=document.getElementById("ddlUser");
    ddlSub = document.getElementById("_ctl0_WorkForm_ddlUser");
    if (isPublic != true) ui.ClearSelect(ddlSub);

    dtb = null;
    str = ddlParent.value;
    if (str.length == 0) {
        ui.InsertItemFirst(ddl, "--默认自己--", "");
        if (isPublic != true) ui.InsertItemFirst(ddlSub, "--默认自己--", "");
    }
    else if (str == "-1") {
        ui.InsertItemFirst(ddl, "--全部--", "-1");
        if (isPublic != true) ui.InsertItemFirst(ddlSub, "--全部--", "-1");
    }
    else {
        if (str.indexOf("！") >= 0) {
            ui.FillSelectByString2(ddl, str, "；", "！");

            // 展开部门层次
            arr1 = new Array();
            arr2 = new Array();
            deptid = "";
            for (i = 0; i < ddl.options.length; i++) {
                if (ddl.options[i].value.indexOf("!") < 0) {
                    deptid = ddl.options[i].value;
                    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.UIHelper', null, null, 'Code=DeptIDList&ParentCode=' + deptid);
                    if (ajax.Completed() == true) {
                        dtb = ajax.GetDataTable();
                        if (dtb != null) {
                            arr1.push(dtb);
                            arr2.push(i + 1);
                        }
                    }
                }
            }
            addqty = 0;
            index = 0;
            for (i = 0; i < arr1.length; i++) {
                index = parseInt(arr2[i]);
                index = index + addqty;
                dtb = arr1[i];
                addqty = addqty + ui.AddItems(ddl, dtb);
            }
        }
        else {
            ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.UIHelper', null, '_ctl0_WorkForm_ddlOrg', 'Code=Dept&ParentCode=Organization');
            if (ajax.Completed() == true) {
                dtb = ajax.GetDataTable();
                ui.FillSelect(ddl, dtb);
            }
        }
        ui.InsertItemFirst(ddl, "--全部--", "-1");
        if (isPublic != true) ui.InsertItemFirst(ddlSub, "--全部--", "-1");
    }

    ddl.selectedIndex = -1;
    ddl.selectedIndex = 0;


    try {

        if (ddl.value == "") {
            LoadShareUser("");
        }
        else {
            var ddlShare = document.getElementById("_ctl0_WorkForm_ddlShare");
            ui.ClearSelect(ddlShare);
            ui.InsertItemFirst(ddlShare, "--全部--", "-1");
            ddlShare.selectedIndex = -1;
            ddlShare.selectedIndex = 0;
        }
    }
    catch (e) { }
}

// 组织机构关联（显示人员）
function LoadUserPersonnel(ddlParent) {
    //ddl=document.getElementById('ddlUser');
    ddl = document.getElementById('_ctl0_WorkForm_ddlUser');
    ui.ClearSelect(ddl);

    str = ddlParent.value;
    if (str.length == 0) {
        ui.InsertItemFirst(ddl, "--默认自己--", "");
    }
    else if (str == "-1") {
        ui.InsertItemFirst(ddl, "--全部--", "-1");
    }
    else {
        if (str.indexOf("!") >= 0) {
            ui.FillSelectByString2(ddl, str, ";", "!");
        }
        else {
            ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.UIHelper', null, '_ctl0_WorkForm_ddlDept', 'Code=Employee&ParentCode=Dept');
            if (ajax.Completed() == true) {
                dtb = ajax.GetDataTable();
                ui.FillSelect(ddl, dtb);
            }
        }
        ui.InsertItemFirst(ddl, "--全部--", "-1");
    }

    ddl.selectedIndex = -1;
    ddl.selectedIndex = 0;

    //以下为共享客户部分使用
    try {
        if (ddl.value == "") {
            LoadShareUser("");
        }
        else {
            var ddlShare = document.getElementById("_ctl0_WorkForm_ddlShare");
            ui.ClearSelect(ddlShare);
            ui.InsertItemFirst(ddlShare, "--全部--", "-1");
            ddlShare.selectedIndex = -1;
            ddlShare.selectedIndex = 0;
        }
    }
    catch (e) {
    }
}
/*
//加载共享用户
function LoadShareUser(UserID)
{

try{

//ddlUser=document.getElementById('_ctl0_WorkForm_ddlUser');//个人
        
ddlShare=document.getElementById("_ctl0_WorkForm_ddlShare");
        
//ui.ClearSelect(ddlShare);
ajax.Begin('Common_Core.dll','Common_Core.MutiModel.CRM_BLL.UIHelper',null,'_ctl0_WorkForm_ddlUser','Code=ShareUser&ParentCode=User&User='+UserID);
if (ajax.Completed()==true)
{
dtb=ajax.GetDataTable();						
ui.FillSelect(ddlShare,dtb);						
}
ui.InsertItemFirst(ddlShare,"--全部--","-1");
ddlShare.selectedIndex = -1;
ddlShare.selectedIndex = 0;
}
catch(e){}
}
*/

// 新建机会
function OpenConfirm(model, id, action, msg, title) {
    url = "/" + ApplicationPath() + "/Common/ConfirmForm.aspx?model=" + model + "&id=" + id + "&action=" + action + "&msg=" + msg + "&title=" + title;
    OpenWindow2(url, title, 2);
}

// 新建机会
function NewChance(custid, demandid) {
    url = "/" + ApplicationPath() + "/crm/sales/SalesChanceEdit.aspx?operation=add&custid=" + custid + "&demandid=" + demandid;
    OpenWindow(url, "新建机会", 3);
}

// 抓取客户/新建机会（泛亚）
function ToPrivateClient(custid) {
    url = "/" + ApplicationPath() + "/crm/sales/NewChance.aspx?custid=" + custid;
    OpenWindow2(url, "抓取客户", 0);
}

// 放弃客户/放弃机会(泛亚)
function ToPublicClient(custid) {
    url = "/" + ApplicationPath() + "/crm/sales/SalesChanceClose.aspx?mode=ToPublic&custid=" + custid;
    OpenWindow2(url, '放弃客户', 0);
}

// 图形分析
function GetGraphAnalyzeUrl(width, height, model, title, x, y, mode, labelCol, valueCol, valueColName) {
    para = "width=" + width + "&height=" + height + "&model=" + model + "&title=" + title + "&x=" + x + "&y=" + y + "&mode=" + mode + "&labelCol=" + labelCol + "&valueCol=" + valueCol + "&valueColName=" + valueColName;
    url = "/" + ApplicationPath() + "/Common/WF/Flow/ReportGraph.aspx?" + para;
    return url;
}

// 图形分析
function ShowGraph(width, height, model, title, x, y, mode, labelCol, valueCol, valueColName) {
    url = GetGraphAnalyzeUrl(width, height, model, title, x, y, mode, labelCol, valueCol, valueColName);
    OpenWindow2(url);
}

// 网格全选
function DataGridSelectAll() {
    inputs = document.body.all.tags("INPUT");
    for (i = 0; i < inputs.length; i++) {
        if (inputs[i].type.toLowerCase() == "checkbox" && inputs[i].id.indexOf("chkAll") >= 0) {
            inputs[i].click();
            break;
        }
    }
}

// 去除空格
function Trim(str) {
    str = str.replace(/\s+/g, "");
    str = str.replace("　", "");
    return str;
}

// 获取当前选择的列表项
function GetSelectedItem(ddl) {
    text = "";
    ddlItem = ddl.children[ddl.selectedIndex];
    if (ddlItem != null && ddlItem.value.length > 0 && ddlItem.value != "-1") {
        text = Trim(ddlItem.text);
    }
    return text;
}

//获取虚拟路径
function ApplicationPath() {
    var sPathName = document.location.pathname;
    var iCount = sPathName.indexOf("/", 1);
    var sPath = sPathName.substring(1, iCount);
    return sPath;
}

function OpenChanceStatusLog(fkid) {
    url = "/Common/Client/ClientTransferShareHistory.aspx?typeIndex=1&mode=Chance&BT=Crm&fkid=" + fkid;
    wShow(url, 600, 420);
}

// 显示竞争对手信息
function ShowCompetitorInfo(id) {
    url = "/" + ApplicationPath() + "/crm/sales/CompetitorEdit.aspx?operation=view$ID=" + id;
    window.showModalDialog('/' + ApplicationPath() + '/MidFrame.aspx?Title=' + escape('显示竞争对手信息') + '&PathURL=' + url, null, "dialogHeight:550px; dialogWidth: 750px; center: yes;help: no;status:no;");
}

// 获取表单参数
function GetPara() {
    para = "";
    if (document.all._ctl0_WorkForm_txtMode != null && document.all._ctl0_WorkForm_txtMode.value.length > 0) {
        para += "&mode=" + document.all._ctl0_WorkForm_txtMode.value
    }
    if (document.all._ctl0_WorkForm_txtCustID != null && document.all._ctl0_WorkForm_txtCustID.value.length > 0) {
        para += "&custid=" + document.all._ctl0_WorkForm_txtCustID.value
    }
    if (document.all._ctl0_WorkForm_txtChanceID != null && document.all._ctl0_WorkForm_txtChanceID.value.length > 0) {
        para += "&chanceid=" + document.all._ctl0_WorkForm_txtChanceID.value
    }
    if (document.all._ctl0_WorkForm_txtLinkmanID != null && document.all._ctl0_WorkForm_txtLinkmanID.value.length > 0) {
        para += "&linkmanid=" + document.all._ctl0_WorkForm_txtLinkmanID.value
    }
    return para;
}

function openlinkmaninfo(linkmanid) {
    return OpenLinkmanInfo(linkmanid);
}

// 显示联系人信息
function OpenLinkmanInfo(linkmanid) {
    url = "/" + ApplicationPath() + "/Common/Client/LinkmanEdit.aspx?operation=view&ID=" + linkmanid;
    OpenWindow2(url, "联系人信息", 2);
}

// 显示客户基本信息
function OpenCustInfo(custid) {
    url = "/" + ApplicationPath() + "/Common/Client/ClientEdit.aspx?operation=view&id=" + custid + "&mode=center";
    OpenWindow3(url, "客户信息", 3);
}
// 客户中心
function OpenCustCenter(custid, BT) {
    BT = BT == null ? "" : BT;
    url = "/" + ApplicationPath() + "/Common/Client/ClientCenter.aspx?operation=edit&BT=" + BT + "&ID=" + custid;
    OpenWindow3(url, "客户信息", 3);
}
function OpenCustCenterHms(custid) {
    url = "/" + ApplicationPath() + "/Common/Client/ClientCenter.aspx?operation=edit&ID=" + custid + "&BT=Hms&mode=center";
    OpenWindow3(url, "客户信息", 3);
}
function OpenCustCenterPes(custid) {
    url = "/" + ApplicationPath() + "/PES/Company/ClientCenter.aspx?operation=edit&ID=" + custid + "&BT=Recruiting&mode=center";
    OpenWindow3(url, "客户信息", 3);
}
function OpenCustCenterBid(custid) {
    url = "/" + ApplicationPath() + "/Common/Client/ClientCenter.aspx?operation=edit&ID=" + custid + "&BT=Bid&mode=center";
    OpenWindow3(url, "客户信息", 3);
}
function OpenCustCenterAcc(custid) {
    //url = "/" + ApplicationPath() + "/Common/Client/ClientCenter.aspx?operation=edit&ID=" + custid + "&BT=Acc&mode=center";
    wShow("/Common/Client/ClientCenter.aspx?operation=edit&ID=" + custid + "&BT=Acc&mode=center&popup=1", 1000, 600);
}
// 客户中心
function OpenCustCenter_ByRecePayID(recepayid) {
    url = "/" + ApplicationPath() + "/Common/Client/ClientCenter.aspx?operation=edit&BT=Acc&mode=center&recepayid=" + recepayid;
    OpenWindow2(url, "客户信息", 3);
}

// 加载联系人
function LoadLinkman(ddl, custid) {

    dtb = null;
    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.Client', function() { if (ajax.Completed() == true) { dtb = ajax.GetDataTable(); } }, custid, 'Key=GetCustLinkman');
    ui.ClearSelect(ddl);
    if (dtb != null) {
        ui.FillSelect(ddl, dtb);

    }
    ui.InsertItemFirst(ddl, "--请选择--", "");
    ddl.value = "";
}



// 加载招聘系统的联系人
function LoadLinkmanOfZP(ddl, custid) {

    dtb = null;
    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.Client', function() { if (ajax.Completed() == true) { dtb = ajax.GetDataTable(); } }, custid, 'Key=GetLinkmanOfZP');
    ui.ClearSelect(ddl);
    if (dtb != null) {

        ui.FillSelect(ddl, dtb);

    }
    ui.InsertItemFirst(ddl, "--请选择--", "");
    ddl.value = "";
}

// 获取联系人的联系电话
function GetLinkmanTel(linkmanid) {

    if (linkmanid.length == 0 || linkmanid == "0" || linkmanid == "-1") return null;
    linkmanInfo = "";
    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.Client', null, null, 'Key=GetLinkmanTel&LinkmanID=' + linkmanid);
    if (ajax.Completed() == true) {
        linkmanInfo = ajax.GetText();
    }
    return linkmanInfo;
}

// 获取客户的上次联系情况
function GetCustLastTimeContactInfo(custid) {
    lasttimeInfo = "";
    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.Client', null, null, 'Key=GetCustLastTimeContact&CustID=' + custid);
    if (ajax.Completed() == true) {
        lasttimeInfo = ajax.GetText();
    }

    return lasttimeInfo;
}

// 新建联系记录
function NewContactHistory(custid) {
    url = "/Common/Client/ContactHistoryEdit.aspx?operation=add&custid=" + custid;
    //OpenWindow(url, "新建联系", 3);
    wShow(url, 800, 600);
}

// 新建联系记录
function NewContactPlan(custid, title, day) {
    url = "/" + ApplicationPath() + "/Common/Client/ContactPlanEdit.aspx?operation=add&custid=" + custid;
    if (day != null) {
        url += "&day=" + day;
    }
    if (title != null) {
        url += "&subject=" + title;
    }
    OpenWindow(url, "新建联系计划", 3);
}

// 显示提示信息
function ShowMessage(message) {
    alert(message);
    location.replace(location.href);
}

// 显示客户的联系记录
function ShowCustContactHistory(custid) {
    wShow("/Common/Client/ContactHistoryList.aspx?operation=view&custid=" + custid, 900, 600);
}

// 显示客户联系人的联系记录
function ShowContactHistory(linkmanid) {
    wShow("/Common/Client/ContactHistoryList.aspx?mode=linkmanedit&operation=view&linkmanid=" + linkmanid, 840, 560);
}

// 显示客户的联系人列表
function showcustlinkman(custid) { return ShowCustLinkman(custid); }
function ShowCustLinkman(custid) {
    url = "/" + ApplicationPath() + "/Common/Client/LinkmanList.aspx?mode=Choose&custid=" + custid;
    OpenWindow2(url, "联系人", 2);
}

// 设置网格显示列
function SetDataGridColumn(model, datagrid) {
    url = "/" + ApplicationPath() + "/Common/BaseData/DataGridColumnSetup.aspx?model=" + model;
    if (datagrid != null) {
        url += "&datagrid=" + datagrid;
    }
    OpenWindow3(url, '显示设置', null, 500, 620);
    return false;
}

// 设置网格导出列
function SetDataGridExportColumn(model, datagrid) {
    if (model.indexOf("_Export") == -1) model = model + "_Export";
    url = "/" + ApplicationPath() + "/Common/BaseData/DataGridColumnSetup.aspx?export=1&model=" + model;
    if (datagrid != null) {
        url += "&datagrid=" + datagrid;
    }
    OpenWindow3(url, '显示设置', null, 500, 620);
    return false;
}

// 获取新编号
function GetNewCode(kind, txtID) {
    code = '';
    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.BaseSet', function() { if (ajax.Completed() == true) { code = ajax.GetText(); } }, null, 'Key=GetOrderNO&kind=' + kind);
    if (txtID != null) {
        document.getElementById(txtID).value = code;
    }
    return code;
}

// 设置返回按钮
function SetReturnButton() {
    btn = document.all.btnReturn;
    if (btn == null) return;
    if (window.dialogArguments != null && window.dialogArguments == "IsModalDialog") {
        btn.value = "关 闭";
    }
    else if (window.opener != null) {
        btn.value = "关 闭";
    }
    else {
        btn.value = "返 回";
    }
}

// 关闭当前窗口或返回上一窗口
function ReturnCloseWindow() {
    if (window.dialogArguments != null && window.dialogArguments == "IsModalDialog") {
        window.close();
    }
    else if (window.opener != null) {
        window.close();
    }
    else {
        if (document.all._ctl0_WorkForm_txtURL == null) {
            history.back(-1);
        }
        else {
            window.location.href = document.all._ctl0_WorkForm_txtURL.value;
        }
    }

    // 页面有缓存时关闭缓存
    if (document.all._ctl0_WorkForm_txtCacheKey != null) {
        ajax.Begin("Common_Core.dll", "Common_Core.MutiModel.CRM_BLL.CacheManager", null, "_ctl0_WorkForm_txtCacheKey", "Key=RemoveCache");
    }
}

// 保存关闭并刷新父窗口
function SaveCloseWindow(prompt) {
    
    if (prompt != null && prompt == true) {
        alert("操作完成。");
    }
    window.returnValue = "ok";
    if (window.dialogArguments != null && window.dialogArguments == "IsModalDialog") {
        window.close();
    }
    else if (window.opener != null) {
        if (window.opener.__doPostBack != null && (document.URL.indexOf("operation=edit") >= 0 || (document.URL.indexOf("operation=add") >= 0 && document.URL.indexOf("popup=1") >= 0))) {
            window.opener.__doPostBack("", "RefreshList");

        }
        else {
            window.opener.location.href = window.opener.location.href;
        }
        window.close();
    }
    else {
        if (document.all.txtURL == null) {
            history.back(-1);
        }
        else {
            window.parent.location.href = document.all.txtURL.value;
        }
    }
}

// 返回选择的PK_ID和sName
function Choose(pk_id, name) {
    r = new Object();
    r[0] = pk_id;
    r[1] = name;
    window.returnValue = r;
    window.close();
}
function Choose5(str1, str2, str3, str4, str5) {
    r = new Object();
    r[0] = str1;
    r[1] = str2;
    r[2] = str3;
    r[3] = str4;
    r[4] = str5;

    window.returnValue = r;
    window.close();
}

function Choose3(str1, str2, str3) {
    r = new Object();
    r[0] = str1;
    r[1] = str2;
    r[2] = str3;
    window.returnValue = r;
    window.close();
}

// 设置textarea的高度
function SetAutoHeight(obj, iframe) {
    obj.style.height = (obj.scrollHeight + 4) + "px";
    if (window.parent && iframe) {
        if(window.parent.document.getElementById(iframe)!=null && window.parent.document.getElementById(iframe)){
            window.parent.document.getElementById(iframe).style.height = window.document.body.scrollHeight + "px";
        }
    }
}


// 关闭编辑窗口
function CloseWindow() {
    if (confirm("是否关闭？") == false) return;
    window.returnValue = null;
    window.close();
}

// 显示窗口
function OpenWindow(url, title, size, h, w) {
    if (h == null) h = 600;
    if (w == null) w = 900;
    if (size != null) {
        switch (size) {
            case 0:
                h = 300;
                w = 450;
                break;
            case 1:
                h = 450;
                w = 600;
                break;
            case 2:
                h = 550;
                w = 800;
                break;
            case 3:
                h = 600;
                w = 900;
                break
            case 4:
                h = 300;
                w = 600;
                break;
            default: // 3
                h = 600;
                w = 900;
                break
        }
    }
    url = AddPopupPara(url);
    url = url.replace(/&/g, "$");
    if (title == null) title = "";
    return window.showModalDialog('/' + ApplicationPath() + '/MidFrame.aspx?Title=' + escape(title) + '&PathURL=' + url, "IsModalDialog", "dialogHeight:" + h + "px; dialogWidth: " + w + "px; center: yes;help: no;status:no;");
}

// 打开网站
function OpenWebsite(url) {
    window.open(url, "", "height=580,width=800,toolbar=yes,status=yes,resizable=yes,scrollbars=yes");
}

// 判断是否在模式窗口中
function IsModal() {
    d = parseInt(self.dialogWidth);
    if (d > 0) {
        return true;
    }
    else {
        return false;
    }
}

// 显示窗口
function OpenWindow2(url, title, size, h, w) {
    // 当前是模式窗口的，再次弹出也必须用模式窗口
    if (IsModal() == true) {
        return OpenWindow(url, title, size, h, w);
    }
    if (h == null) h = 600;
    if (w == null) w = 900;
    if (size != null) {
        switch (size) {
            case 0:
                h = 300;
                w = 450;
                break;
            case 1:
                h = 450;
                w = 600;
                break;
            case 2:
                h = 550;
                w = 800;
                break;
            default:
                h = 600;
                w = 900;
                break
        }
    }
    url = AddPopupPara(url);
    frmNewOpen = window.open(url, title, "height=" + h + ",width=" + w + ",toolbar=no,status=yes,resizable=yes,scrollbars=yes");
    frmNewOpen.opener = window;
    frmNewOpen.window.moveTo((screen.availWidth - w) / 2, (screen.availHeight - h) / 2);
    return frmNewOpen;
}

function AddPopupPara(url) {
    if (url.indexOf("?") > 0) {
        url = url + "&popup=1";
    }
    else {
        url = url + "?popup=1";
    }
    return url;
}

// 显示窗口（在新窗口）
function OpenWindow3(url, title, size, h, w) {
    // 当前是模式窗口的，再次弹出也必须用模式窗口
    if (IsModal() == true) {
        return OpenWindow(url, title, size, h, w);
    }
    if (h == null) h = 600;
    if (w == null) w = 900;
    if (size != null) {
        switch (size) {
            case 0:
                h = 300;
                w = 450;
                break;
            case 1:
                h = 450;
                w = 600;
                break;
            case 2:
                h = 550;
                w = 800;
                break;
            default:
                h = 600;
                w = 1000;
                break
        }
    }
    url = AddPopupPara(url);
    var l = (screen.availWidth - w) / 2;
    var t = (screen.availHeight - h) / 2;
    frmNewOpen = window.open(url, "_blank", "left=" + l + ",top=" + t + ",height=" + h + ",width=" + w + ",toolbar=no,status=yes,resizable=yes,scrollbars=yes");
    frmNewOpen.opener = window;
}

function OpenNew(url) {
    h = 600;
    w = 900;
    frm = window.open(url, "", "height=" + h + ",width=" + w + ",menubar=yes,toolbar=yes,status=yes,resizable=yes,scrollbars=yes");
    return frm;
}

// 选择应收应付账户
function ChooseRecePay(txtID, txtName, custName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    para = "";
    if (custName != null) para = "&custname=" + custName;
    url = "/" + ApplicationPath() + "/Common/Client/ClientList.aspx?mode=choosesingle&onlyRecepay=1" + para;

    r = OpenWindow(url, "选择往来单位", 2);
    if (r != null && objID != null && objName != null) {
        objID.value = r[0];
        objName.value = unescape(r[2]);
        objName.title = objName.value;
    }
    return r;
}

// 选择客户（多选）
function ChooseCust2(txtID, txtName, custName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    para = "";
    if (custName != null) para = "&custname=" + custName;
    url = "/" + ApplicationPath() + "/Common/Client/ClientList.aspx?mode=choose&custidControl=" + txtID + "&custnameControl=" + txtName + para;
    r = OpenWindow(url, "选择", null, 575, 835);
    if (r != null && objID != null && objName != null) {
        objID.value = r[0];
        objName.value = unescape(r[1]);
        objName.title = objName.value;
    }
    return r;
}
var s_txtID;
var s_txtName;
// 选择客户
function ChooseCust(txtID, txtName, custName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    s_txtID = txtID;
    s_txtName = txtName;
    para = "";
    if (custName != null) para = "&custname=" + custName;
    url = "/Common/Client/ClientList.aspx?mode=choosesingle&custidControl=" + txtID + "&custnameControl=" + txtName + para;
    wShow(url, 900, 600);
}
function setChoose(r) {
    objID = document.getElementById(s_txtID);
    objName = document.getElementById(s_txtName);
    if (r != null && objID != null && objName != null) {
        objID.value = r[0];
        objName.value = unescape(r[2]);
    }
}
// 选择客户HMS
function ChooseCustHMS(txtID, txtName, custName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    para = "";
    if (custName != null) para = "&custname=" + custName;
    //xzd has edit it ad 2009-04-27 use to test
    //debugger;
    url = "/" + ApplicationPath() + "/Common/Client/ClientList.aspx?BT=Hms&mode=choosesingle&custidControl=" + txtID + "&custnameControl=" + txtName + para;
    //url="/oa/crm/client/ClientList.aspx?BT=Hms&mode=
    //&custidControl="+txtID+"&custnameControl="+txtName+para;
    r = OpenWindow(url, "选择", null, 575, 835);
    if (r != null && objID != null && objName != null) {
        objID.value = r[0];
        objName.value = unescape(r[2]);
        objName.title = objName.value;
    }
    return r;
}

// 选择竞争对手
function ChooseCompetitor(txtID, txtName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    url = "/" + ApplicationPath() + "/CRM/Sales/CompetitorList.aspx?mode=choosesingle";
    result = window.showModalDialog('../../MidFrame.aspx?Title=' + escape('选择竞争对手') + '&PathURL=' + url, null, "dialogHeight:600px; dialogWidth: 800px; center: yes;help: no;status:no;");
    if (result != null && objID != null && objName != null) {
        objID.value = result[0];
        objName.value = result[1];
    }
    return result;
}

// 选择联系人
function ChooseLinkman(txtCustID, txtID, txtName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    custid = document.getElementById(txtCustID).value;
    if (custid == "") {
        alert('请先选择客户！')
        return;
    }
    url = "/" + ApplicationPath() + "/Common/Client/LinkmanList.aspx?mode=Choose$custid=" + custid + "$selected=" + objID.value;
    result = window.showModalDialog('../../MidFrame.aspx?Title=' + escape('选择联系人') + '&PathURL=' + url, null, "dialogHeight:400px; dialogWidth: 600px; center: yes;help: no;status:no;");
    if (result != null && objID != null && objName != null) {
        objID.value = result[0];
        objName.value = result[1];
    }
    return result;
}

// 选择联系人
function ChooseSingleLinkman(txtCustID, txtID, txtName) {
    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    custid = document.getElementById(txtCustID).value;
    if (custid == "") {
        alert('请先选择客户！')
        return;
    }
    url = "/" + ApplicationPath() + "/Common/Client/LinkmanList.aspx?mode=ChooseSingle$custid=" + custid + "$selected=" + objID.value;
    result = window.showModalDialog('../../MidFrame.aspx?Title=' + escape('选择联系人') + '&PathURL=' + url, null, "dialogHeight:400px; dialogWidth: 750px; center: yes;help: no;status:no;");
    if (result != null && objID != null && objName != null) {
        objID.value = result[0];
        objName.value = result[1];
    }
    return result;
}

// 选择联系人
function ChooseLinkman2(custid, linkmanID) {
    obj = document.getElementById(linkmanID);
    objName = document.getElementById(linkmanID + "_Name");
    url = "/" + ApplicationPath() + "/Common/Client/LinkmanList.aspx?operation=choose$custid=" + custid + "$selected=" + obj.value;
    result = window.showModalDialog('../../MidFrame.aspx?Title=' + escape('请选择') + '&PathURL=' + url, null, "dialogHeight:400px; dialogWidth: 600px; center: yes;help: no;status:no;");
    if (result != null && obj != null && objName != null) {
        obj.value = result[0];
        objName.value = result[1];
    }
    return false;
}
var s_id_s;
// 选择CRM基本资料（多选）
function ChooseBaseData(sign, id) {
    obj = document.getElementById(id);
    objName = document.getElementById(id + "_Name");
    s_id_s = id;
    url = "/Common/BaseData/ChooseBaseData.aspx?sign=" + sign + "&selected=" + obj.value;
    wShow(url, 360, 400);
}

function set_BaseData(r) {
    obj = document.getElementById(s_id_s);
    objName = document.getElementById(s_id_s + "_Name");
    if (r != null && obj != null && objName != null) {
        obj.value = r[0];
        objName.value = r[1];
    }
}

// 返回上一页
function PageBack() {
    history.back(-1);
}

// 显示员工信息
function showEmpInfo(id) {
    url = "/" + ApplicationPath() + "/settings/UserProfile.aspx?AllBook=true$operation=view$ID=" + id;
    window.showModalDialog('../MidFrame.aspx?Title=' + escape('显示员工信息') + '&PathURL=' + url, null, "dialogHeight:550px; dialogWidth: 750px; center: yes;help: no;status:no;");
}

// 流程信息
function openflowinfo(url) {
    h = 480;
    w = 850;
    flowinf = window.open(url, "flow", "height=" + h + ",width=" + w + ",toolbar=no,status=yes,resizable=no,scrollbars=yes");
    flowinf.window.moveTo((screen.availWidth - w) / 2, (screen.availHeight - h) / 2);
}
// 流程信息
function openflowinfo2(flowid, modcode) {
    url = "/" + ApplicationPath() + "/workflow/flowsetaddup.aspx?view=1&flowid=" + flowid + "&modcode=" + modcode;
    h = 480;
    w = 850;
    flowinf = window.open(url, "flow", "height=" + h + ",width=" + w + ",toolbar=no,status=yes,resizable=no,scrollbars=yes");
    flowinf.window.moveTo((screen.availWidth - w) / 2, (screen.availHeight - h) / 2);
}

// 选择人员，说明：iSelectModal表示单选还是多选，1表示单选，2表示多选，默认多选//
function selectEmployee(txtID, txtName, iSelectModal) {

    objID = document.getElementById(txtID);
    objName = document.getElementById(txtName);
    var iModal = iSelectModal == null ? 2 : iSelectModal;
    result = window.showModalDialog('/' + ApplicationPath() + '/MidFrame.aspx?Title=' + escape('选择人员') + '&PathURL=/' + ApplicationPath() + '/Common/Mod/SelMultEmp.aspx?Selecteduserid=' + objID.value + '$iModal=' + iModal, 'selemp', 'dialogWidth:680px; dialogHeight:510px; center:yes;toolbar:no;status:no;resizable:no;scrollbars:no;help:no');

    if (result != null && objID != null && objName != null) {
        if (result.indexOf('@') != -1) {
            return true;
        }
        if (result == "") {
            objID.value = "";
            objName.value = "";
        }
        else {
            objID.value = result;
            ajax.Begin('Common_Core.dll', 'Eqccdservice.FormQuery', function() { }, txtID, 'Key=GetSelectName');
            if (ajax.Completed() == true) {
                //debugger;
                objName.value = ajax.GetText();
            }
        }
        return true;
    }

    r = new Object();
    r[0] = objID.value;
    r[1] = objName.value;

    return r;
}

// 选择人员
function selectEmp(targetid, targetidHidden) {
    result = window.showModalDialog('/' + ApplicationPath() + '/MidFrame.aspx?Title=' + escape('选择人员') + '&PathURL=/' + ApplicationPath() + '/Common/Mod/SelMultEmp.aspx?Selecteduserid=', 'selemp', 'dialogWidth:600px; dialogHeight:510px; center:yes;toolbar:no;status:no;resizable:no;scrollbars:no;help:no')
    if (result != null && result != '') {
        document.getElementById(targetidHidden).value = result;
        ajax.Begin('Common_Core.dll', 'Eqccdservice.FormQuery', function() { }, targetidHidden, 'Key=GetSelectName');
        if (ajax.Completed() == true) {
            document.getElementById(targetid).value = ajax.GetText();
            document.getElementById(targetid).title = document.getElementById(targetid).value;
        }
        return true;
    }
    return false;
}

// 选择机构部门
function selectDept(depName, depID, branchID) {
    result = window.showModalDialog('/' + ApplicationPath() + '/MidFrame.aspx?Title=' + escape('选择机构部门') + '&PathURL=/' + ApplicationPath() + '/Mod/SelectOrgDept.aspx?Selecteduserid=', 'selemp', 'dialogWidth:600px; dialogHeight:300px; center:yes;toolbar:no;status:no;resizable:no;scrollbars:no;help:no')
    if (result != null && result != '') {
        //debugger;
        var count = result.indexOf(',');
        if (count == 1) {
            var arryID = result.split(',');
            var text = null;
            ajax.Begin('Common_Core.dll', 'Eqccdservice.FormManager', function() { if (ajax.Completed() == true) { text = ajax.GetText(); } }, null, "Key=GetDepName&FormID=" + arryID[1]);
            if (text != null) {
                document.getElementById(depName).value = text;
            }

            document.getElementById(branchID).value = arryID[0];   //机构Id
            document.getElementById(depID).value = arryID[1];   //部门Id
            return true;
        }
    }
    return false;
}

// 返回当前操作员的ID和Name
function GetCurrentEmp() {
    obj = new Object();
    ajax.Begin('Common_Core.dll', 'Eqccdservice.FormQuery', function() { }, null, 'Key=GetCurrentEmp');
    if (ajax.Completed() == true) {
        idname = ajax.GetText();
        if (idname.length > 0) {
            obj = idname.split(",");
        }
    }
    return obj;
}

//选择机构部门
function selectOrgDept(targetid, targetidHidden) {
    var result = window.showModalDialog('/' + ApplicationPath() + '/MidFrame.aspx?Title=' + escape('选择人员') + '&PathURL=/' + ApplicationPath() + '/WorkFlow/wmstepassgnset.aspx?OrgDept=1', 'assgn', 'dialogWidth:600; dialogHeight:500; center:yes;toolbar:no;status:no;resizable:no;scrollbars:no;help:no')
    if (result != null && result != '') {
        document.getElementById(targetidHidden).value = result;
        ajax.Begin('Common_Core.dll', 'Eqccdservice.FormQuery', function() { }, targetidHidden, 'Key=GetSelectName');
        if (ajax.Completed() == true) {
            document.getElementById(targetid).value = ajax.GetText();
        }
        return true;
    }
    return false;
}
//弹出窗口
function openflow(url) {
    var flowinf = window.open(url, "flow", "toolbar=no,status=yes,resizable=yes,scrollbars=yes")
    flowinf.moveTo(20, 20)
    flowinf.resizeTo(660, screen.availHeight - 70)
    flowinf.focus()
}

//标准化的人员、部门等选取--------------------------------------------------------------
//选取多个人员，同时显示已选取的人员		
function selmultemp(stype, click, selempid) {
    window.open("/" + ApplicationPath() + "/mod/SelmultEmp.aspx?type=" + stype + "&click=" + click + "&selempid=" + selempid, "selemp", "toolbar=no,status=no,resizable=no,scrollbars= yes")
}

//选取单个人员
function selemp(stype, click, ControlID, ControlName) {
    //stiven [2007.11.16]
    //window.open("/OA/mod/SelEmp.aspx?type="+stype+"&click="+click,"selsingleemp","toolbar=no,status=no,resizable=no,scrollbars= yes")
    winOpen("/" + ApplicationPath() + "/Common/mod/SelEmp.aspx?type=" + stype + "&click=" + click + "&ControlID=" + ControlID + "&ControlName=" + ControlName, 560, 450);
}

//根据范围来选取单个人员
function rightselemp(stype, click, code) {
    window.open("/" + ApplicationPath() + "/mod/SelSingleEmp.aspx?rightsel=1&type=" + stype + "&click=" + click + "&code=" + code, "selsingleemp", "toolbar=no,status=no,resizable=no,scrollbars= no")
}

//根据范围来选取多个人员
function rightmultselemp(stype, click, code) {
    window.open("/" + ApplicationPath() + "/mod/SelMultEmp.aspx?rightsel=1&type=" + stype + "&click=" + click + "&code=" + code, "SelMultEmp", "toolbar=no,status=no,resizable=no,scrollbars= no")
}

//选取部门
function seldep(stype, click, multsel) {
    window.open("/" + ApplicationPath() + "/mod/seldep.aspx?type=" + stype + "&click=" + click + "&multsel=" + multsel, "seldep", "toolbar=no,status=no,resizable=no,scrollbars= no")
}
function userdetailinfo(id) {
    //window.open('/OA/Settings/UserInfo.aspx?PK_ID='+id,'newwindow','width=400px,height=250px,center=yes,Status=no')
    winOpen('/' + ApplicationPath() + '/Settings/UserInfo.aspx?PK_ID=' + id, 550, 380);
}
//标准化的人员、部门等选取结束
//---------------------------------------------------------------------------------------------


//用于在DataGrid实现全选---------------------------------------------------
function All() {
    var whichIt = event.srcElement;
    while (whichIt.tagName.indexOf("FORM") == -1) {
        whichIt = whichIt.parentElement;
        if (whichIt == null) { return true; }
    }

    var length = whichIt.elements.length
    var tocheck = whichIt.SelAll.checked
    for (var i = 0; i < length; i++) {
        if (whichIt.elements[i].name.indexOf("d") != -1)
            if (whichIt.elements[i].disabled == false) {
            whichIt.elements[i].checked = tocheck
        }
    }
    return;
}

function SetAll() {
    var whichIt = event.srcElement;
    while (whichIt.tagName.indexOf("FORM") == -1) {
        whichIt = whichIt.parentElement;
        if (whichIt == null) { return true; }
    }
    if (1 == whichIt.SelAll.checked) {
        whichIt.SelAll.checked = 0
    }
    else {
        whichIt.SelAll.checked = 1
    }
    All()
    return;
}
//用于在DataGrid实再全选结束
//------------------------------------------------------------------------

//用于图形显时-------------------------------------------
//图形显示时图片点击
function onSliceClicked(pointIndex) {
    var objSeries = document.Form1.elements["SeriesTooltip"];
    var objLegend = document.Form1.elements["LegendTooltip"];

    var parameters = "seriesTooltip=" + objSeries.options[objSeries.selectedIndex].value;
    parameters = parameters + "&legendTooltip=" + objLegend.options[objLegend.selectedIndex].value;

    document.Form1.elements["Chart1"].ImageUrl = "ImageMapToolTipsChart.aspx?" + parameters;

    document.images["Chart1"].src = document.Form1.elements["Chart1"].ImageUrl;
    //alert(document.Form1.elements["Chart1"].ImageUrl);
}
//用于图形显结束
//----------------------------------------------------------

//用JavaScript操作COOKIE---------------------------------------------------
//保存COOKIE
function SetCookie(name, value, expires, path, domain, secure) {
    var tmp = name.split("."), str, reg
    if (tmp.length == 1) {
        document.cookie = tmp[0] + "=" + value;
        if (expires) {
            var exp = new Date();
            var oneMin = exp.getTime() + expires;
            exp.setTime(oneMin);
            document.cookie += ";expires=" + exp.toGMTString();
        }
        document.cookie += ((path) ? ";path=" + path : "");
        document.cookie += ((domain) ? ";domain=" + domain : "");
        document.cookie += ((secure) ? ";secure=" + secure : "");
        return;
    }

    if (str = GetCookie(name)) {
        var reg = new RegExp("(^|&)" + tmp[1] + "=" + str)
        SetCookie(tmp[0], GetCookie(tmp[0]).replace(reg, "$1" + tmp[1] + "=" + value), expires, path, domain, secure)
        return;
    }
    if (str = GetCookie(tmp[0])) {
        SetCookie(tmp[0], str + "&" + tmp[1] + "=" + value, expires, path, domain, secure)
        return;
    }
    SetCookie(tmp[0], tmp[1] + "=" + value, expires, path, domain, secure)
}

//获得COOKIE
function GetCookie(name) {
    var tmp = name.split(".");
    var arr, reg = new RegExp("(^| )" + tmp[0] + "=([^;]*)");
    if (!(arr = document.cookie.match(reg))) {
        return "";
    }
    if (tmp[1] == null) return arr[2];
    reg = new RegExp("(^|&)" + tmp[1] + "=([^&]*)");
    if (!(arr = arr[2].match(reg))) return "";

    return arr[2];
}
//用JavaScript操作COOKIE结束
//--------------------------------------------------------------------------------------------


//首页用到的javascript-----------------------------

//打开帮助
function onlineHelp() {
    var newwin = window.open("help/help.htm", "HelpWin", "toolbar=yes location=no scrollbars=yes menubar=no status=yes resizable=1 width=640 height=450 left=0 top=20");
    newwin.focus();
    return false;
}

function reSize() {
    var expires = 30 * 24 * 60 * 60 * 1000;
    var controlstate = GetCookie("OA.tree")
    if (controlstate == "") {
        controlstate = 0;
        SetCookie("OA.tree", 0, expires, "/");
    }
    var oFrame = parent.document.all("MenuFrame");

    var oFrame1 = parent.document.all("LogoFrame");
    if (controlstate == 1) {
        oFrame.style.width = 0;
        oFrame1.style.width = 0;
        controlstate = 0;
        SetCookie("OA.tree", 0, expires, "/");
        frm.control.src = "img/control.gif"
    } else {
        oFrame1.style.width = 175;
        oFrame.style.width = 175;
        controlstate = 1;
        SetCookie("OA.tree", 1, expires, "/");
        frm.control.src = "img/control1.gif"
    }
}
//打开万年历
//function opencal()
//{
//	var cal = window.open("/OA/set/calendar.aspx","calWin", "location=no scrollbars=yes menubar=no status=no resizable=0");
//	cal.moveTo((window.screen.availWidth-500)/2,(window.screen.availHeight-450)/2)
//	cal.resizeTo(500,450)
//	cal.focus();
//}
//打开自定义功能树
function openTree() {
    var pwdfrm = window.open("/" + ApplicationPath() + "/tree/tree_index.aspx", "", "scrollbars=yes status=yes menubar=no resizable=1,width=780,height=500");
    l = (window.screen.availWidth - 700) / 2
    t = (window.screen.availHeight - 500) / 2
    pwdfrm.window.moveTo(l, t)
    pwdfrm.window.resizeTo(700, 500)
    pwdfrm.focus();
    return false;
}
//刷新
function OAreload() {
    window.parent.location.reload()
}
//打开自定义快捷工具栏
function openTitleBar() {
    var pwdfrm = window.open("/" + ApplicationPath() + "/set/setTitleBar.aspx", "tr", "scrollbars=yes status=yes menubar=no resizable=1,width=520,height=320");
    pwdfrm.moveTo((window.screen.availWidth - 600) / 2, (window.screen.availHeight - 500) / 2)
    pwdfrm.resizeTo(600, 500)
    pwdfrm.focus();
    return false;
}
//打开颜色配置
function openColor() {
    var pwdfrm = window.open("/" + ApplicationPath() + "/set/setColor.aspx", "tr", "scrollbars=yes status=yes menubar=no resizable=1,width=520,height=320");
    l = (window.screen.availWidth - 680) / 2
    t = (window.screen.availHeight - 500) / 2
    pwdfrm.window.moveTo(l, t)
    pwdfrm.window.resizeTo(680, 500)
    pwdfrm.focus();
    return false;
}
//显示在线人数
function showonline() {
    frm = window.open("/" + ApplicationPath() + "/set/onlineper.aspx?v=ss5", "frm", "toolbar=no,status=yes,resizable=yes,scrollbars=yes")
    frm.window.moveTo(20, 20)
    frm.focus()
}


function setloc() {
    if (parent.frames.length == 0) {
        window.moveTo(20, 20)
        window.resizeTo(610, screen.availHeight - 70)
    }
}

function closewin() {
    if (parent.frames.length > 0) {
        location.replace("/" + ApplicationPath() + "/desktop.aspx")
    } else {
        window.close()
    }

}
function re() {
    location.replace("logo.aspx")
}
function ShowStat(strTitle) {
    //winOpen('/' + ApplicationPath() + '/Common/Component/StructAnalyseImage.aspx?sTitle=' + strTitle, 850, 550);
}
//首页用的javascript结束
//-------------------------------------------------------------------------
function winOpen(SetUrl, SetW, SetH, title) {
    var windowW = SetW;
    var windowH = SetH;
    var windowX = Math.ceil((window.screen.width - windowW) / 2);
    var windowY = Math.ceil((window.screen.height - windowH) / 2); //确定网页的坐标
    window.open(SetUrl, title, 'scrollbars=yes,resizable=yes,top=' + windowY + ',left=' + windowX + ', width=' + windowW + ',height=' + windowH + '');
}
//-----------------查看流程 ddlist列表框  sModCode流程编码
function ShowFlow(ddlistName, sModCode) {
    var obj = document.getElementById(ddlistName);
    if (obj.value == "-1") {
        alert('不使用流程');
    }
    else {
        FlowView(obj.value, sModCode);
    }
}
//流程查看
function FlowView(sFK_FlowID, sModCode) {
    if (sFK_FlowID != "" && sModCode != "") {
        //var win=OpenWindow('/OA/workflow/flowsetaddup.aspx?view=1&flowid='+sFK_FlowID+'&modcode='+sModCode,'流程信息',null,500,850);
        var win = winOpen('/' + ApplicationPath() + '/Common/wf/workflow/flowsetaddup.aspx?view=1&flowid=' + sFK_FlowID + '&modcode=' + sModCode, 850, 500);
    }
    else {
        alert('参数错误,无法查看流程信息！');
    }
}
//帐务修改
function actionedit(sCode) {
    winOpen('FundOpt.aspx?sCode=' + sCode, 750, 500);
}
//帐务查看
function FundRecView(sCode) {
    winOpen('FundOpt.aspx?opt=view&sCode=' + sCode, 750, 500);
}
//帐务作废
function FuntionAccountCancel(iCancel, sCode, BtnReload, iClose) {
    var strMsg = '';
    if (iCancel == '1') { strMsg = '作废'; } else { strMsg = '有效'; }
    if (confirm('单据编号：' + sCode + '\n\n您确定要使它' + strMsg + '吗？')) {
        var strTemp = "";
        ajax.Begin('CRM_Core.dll', 'CRM_Core.BaseSet', function() { if (ajax.Completed() == true) { strTemp = ajax.GetText(); } }, null, 'Key=AccountCancel&ParentID=' + sCode + '&iType=' + iCancel);
        if (strTemp == "成功") {
            if (BtnReload != '') { opener.document.getElementById(BtnReload).click(); }
            if (iClose == '1') { self.close(); }
        }
        alert(strTemp);
    }
    else {
        return false;
    }
}
//非数字过滤
function clearNoNum(obj) {
    //先把非数字的都替换掉，除了数字和.
    obj.value = obj.value.replace(/[^\d.]/g, "");
    //必须保证第一个为数字而不是.
    obj.value = obj.value.replace(/^\./g, "");
    //保证只有出现一个.而没有多个.
    obj.value = obj.value.replace(/\.{2,}/g, ".");
    //保证.只出现一次，而不能出现两次以上
    obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
}

function SendMail(sMail) {
    sendMail(sMail, "");
}
function sendMail(sMail, args) {
    //var re;
    //re = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
    //if (re.test(sMail))//有效
    //{
        var index = window.location.pathname.indexOf("/", 1)
        var RootPath = window.location.pathname.substring(0, index + 1)
        winOpen(RootPath + 'Common/Email/SendMail.aspx?Address=' + sMail + args, 850, 560);
    //}
    //else { alert('经检测，该E-Mail不是合法的E-Mail，操作失败！') }
}

function ResumeShowList(RID, iType) {
    var url = "/" + ApplicationPath() + "/HMS/Resume/contactlist.aspx?RID=" + RID + "&iType=" + iType;
    winOpen(url, 850, 450);
    //alert(RID+'-'+iType);
}

/***************************BID***********************/
function IsAction() {
    var pic = document.getElementsByTagName('IMG');
    var sAction = "view";
    for (i = 0; i < pic.length; i++) {
        if (pic[i].title == "点击编辑") {
            sAction = "edit";
        }
    }
    return sAction;
}
// iType：1表示公司,2表报价 priceType：报价类型 TimeStar,TimeEnd：报价有效期开始与结束
function ShowList(PID, iType, priceType, TimeStar, TimeEnd) {
    priceType = priceType == null ? "" : priceType;
    TimeStar = TimeStar == null ? "" : TimeStar;
    TimeEnd = TimeEnd == null ? "" : TimeEnd;
    var sUrl = "";
    var sAction = IsAction()
    if (parseInt(iType) == 2) {
        sUrl = "ProductPriceList.aspx?show=one&operation=" + sAction + "&PID=" + PID + "&iPriceType=" + priceType + "&DateStar=" + TimeStar + "&DateEnd=" + TimeEnd;
    }
    else {
        sUrl = "ProductPriceCompanyList.aspx?show=one&operation=" + sAction + "&PID=" + PID + "&iPriceType=" + priceType + "&DateStar=" + TimeStar + "&DateEnd=" + TimeEnd;
    }
    winOpen(sUrl, 800, 560);
}




// 修改：组织机构关联（显示部门）
function LoadDeptPersonnelClient(ddlParent, isPublic) {
    debugger;
    var share = document.getElementById("_ctl0_WorkForm_txtShareId");
    if (share != null) {
        document.getElementById("_ctl0_WorkForm_txtShareId").value = "";
    }
    document.getElementById("_ctl0_WorkForm_hidUserID").value = "";
    //ddl=document.getElementById("ddlDept");
    ddl = document.getElementById("_ctl0_WorkForm_ddlDept");
    ui.ClearSelect(ddl);

    //ddlSub=document.getElementById("ddlUser");
    ddlSub = document.getElementById("_ctl0_WorkForm_ddlUser");
    if (isPublic != true) ui.ClearSelect(ddlSub);

    dtb = null;
    str = ddlParent.value;
    var pulicAppendObj = document.getElementById("_ctl0_WorkForm_chkPublicAppend");
    var publicOnlyObj = document.getElementById("_ctl0_WorkForm_chkPublicOnly");


    if (str.length == 0) {
        ui.InsertItemFirst(ddl, "--默认自己--", "");
        if (isPublic != true) ui.InsertItemFirst(ddlSub, "--默认自己--", "");


        if (publicOnlyObj != null && pulicAppendObj != null) {
            pulicAppendObj.checked = false;
            publicOnlyObj.checked = false;
            pulicAppendObj.disabled = "disabled";
            publicOnlyObj.disabled = "disabled";
        }
    }
    else if (str == "-1") {
        ui.InsertItemFirst(ddl, "--全部--", "-1");
        if (isPublic != true) ui.InsertItemFirst(ddlSub, "--全部--", "-1");

        if (publicOnlyObj != null && pulicAppendObj != null) {

            pulicAppendObj.disabled = "";
            publicOnlyObj.disabled = "";
        }
    }
    else {
        if (publicOnlyObj != null && pulicAppendObj != null) {

            pulicAppendObj.disabled = "";
            publicOnlyObj.disabled = "";
        }
        if (str.indexOf("！") >= 0) {
            debugger;
            ui.FillSelectByString2(ddl, str, "；", "！");

            // 展开部门层次
            arr1 = new Array();
            arr2 = new Array();
            deptid = "";
            for (i = 0; i < ddl.options.length; i++) {
                if (ddl.options[i].value.indexOf("!") < 0) {
                    deptid = ddl.options[i].value;
                    ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.UIHelper', null, null, 'Code=DeptIDList&ParentCode=' + deptid);
                    if (ajax.Completed() == true) {
                        dtb = ajax.GetDataTable();
                        if (dtb != null) {
                            arr1.push(dtb);
                            arr2.push(i + 1);
                        }
                    }
                }
            }
            addqty = 0;
            index = 0;
            for (i = 0; i < arr1.length; i++) {
                index = parseInt(arr2[i]);
                index = index + addqty;
                dtb = arr1[i];
                addqty = addqty + ui.AddItems(ddl, dtb);
            }
        }
        else {
            ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.UIHelper', null, '_ctl0_WorkForm_ddlOrg', 'Code=Dept&ParentCode=Organization');
            if (ajax.Completed() == true) {
                dtb = ajax.GetDataTable();
                ui.FillSelect(ddl, dtb);
            }
        }
        ui.InsertItemFirst(ddl, "--全部--", "-1");
        if (isPublic != true) ui.InsertItemFirst(ddlSub, "--全部--", "-1");
    }

    ddl.selectedIndex = -1;
    ddl.selectedIndex = 0;


    try {

        if (ddl.value == "") {
            LoadShareUser("");
        }
        else {
            var ddlShare = document.getElementById("_ctl0_WorkForm_ddlShare");
            ui.ClearSelect(ddlShare);
            ui.InsertItemFirst(ddlShare, "--全部--", "-1");
            ddlShare.selectedIndex = -1;
            ddlShare.selectedIndex = 0;
        }
    }
    catch (e) { }
}
function LoadUserPersonnelClient(ddlParent) {
    var share = document.getElementById("_ctl0_WorkForm_txtShareId");
    if (share != null) {
        document.getElementById("_ctl0_WorkForm_txtShareId").value = "";
    }
    document.getElementById("_ctl0_WorkForm_hidUserID").value = "";
    //ddl=document.getElementById('ddlUser');
    ddl = document.getElementById('_ctl0_WorkForm_ddlUser');
    ui.ClearSelect(ddl);
    debugger;
    str = ddlParent.value;
    var pulicAppendObj = document.getElementById("_ctl0_WorkForm_chkPublicAppend");
    var publicOnlyObj = document.getElementById("_ctl0_WorkForm_chkPublicOnly");
    if (str.length == 0) {
        ui.InsertItemFirst(ddl, "--默认自己--", "");
    }
    else if (str == "-1") {
        ui.InsertItemFirst(ddl, "--全部--", "-1");
        if (publicOnlyObj != null && pulicAppendObj != null) {

            pulicAppendObj.disabled = "";
            publicOnlyObj.disabled = "";
        }
    }
    else {
        if (str.indexOf("!") >= 0) {
            ui.FillSelectByString2(ddl, str, ";", "!");
        }
        else {
            ajax.Begin('Common_Core.dll', 'Common_Core.MutiModel.CRM_BLL.UIHelper', null, '_ctl0_WorkForm_ddlDept', 'Code=Employee&ParentCode=Dept');
            if (ajax.Completed() == true) {
                dtb = ajax.GetDataTable();
                ui.FillSelect(ddl, dtb);
            }
        }
        ui.InsertItemFirst(ddl, "--全部--", "-1");

        if (publicOnlyObj != null && pulicAppendObj != null) {

            pulicAppendObj.disabled = "";
            publicOnlyObj.disabled = "";
        }
    }

    ddl.selectedIndex = -1;
    ddl.selectedIndex = 0;

    //以下为共享客户部分使用
    try {
        if (ddl.value == "") {
            LoadShareUser("");
        }
        else {
            var ddlShare = document.getElementById("_ctl0_WorkForm_ddlShare");
            ui.ClearSelect(ddlShare);
            ui.InsertItemFirst(ddlShare, "--全部--", "-1");
            ddlShare.selectedIndex = -1;
            ddlShare.selectedIndex = 0;
        }
    }
    catch (e) {
    }
}
/**
弹出新页面通用方法
-------------------------
url:要弹出页面的地址【目标地址页，必须设置标题】
height:要弹出的页面高度
width:要弹出的页面宽度
Author:_No.13
Time:2011-03-23
-------------------------
**/
function wShow(url, width, height) {
    var left = parseInt((screen.availWidth - width) / 2);
    var top = parseInt((screen.availHeight - height) / 2);
    url = '/' + ApplicationPath() + url;
    return window.open(url, '', 'height=' + height + ', width=' + width + ', top=' + top + ', left=' + left + ', toolbar=no, menubar=no,              scrollbars=yes, resizable=yes,location=no,status=no');
}